<template>
	<view class="recruitment-overview">
		<view class="recruitment-top">
			<view class="recruitment-search" @click="goSetJopSearch">
				<image class="image-search" src="@/static/image/searchimg.png" />
				<input type="text" placeholder="木工" placeholder-class="placeholder-input" disabled="false" />
			</view>
			<view class="recruitment-menu">
				<view class="recruitment-menu-item" v-for="(item,index) in menuList" :key="index" @click="goSetJopSort(item)">
					<text>{{item.name}}</text>
				</view>
			</view>
		</view>
		<view class="content">
			<you-scroll ref="scroll" :fetch="SetJopData">
				<view class="recruitment-item" slot-scope="{row,index}" @click="SetJopDetail(row,index)">
					<recruitment-list-item :item="row"></recruitment-list-item>
				</view>
			</you-scroll>
		</view>
	</view>
</template>

<script>
	import {
		setJobList
	} from '@/static/js/api/jop.js';
	import request from '@/static/js/request.js'
	import RecruitmentListItem from './components/RecruitmentListItem.vue'
	import youScroll from '@/components/uni-list-scroll/you-scroll'
	export default {
		components: {
			RecruitmentListItem,
			youScroll
		},
		data() {
			return {
				menuList: [{
						name: "招个人",

					},
					{
						name: "招班组",

					},
					{
						name: "全部分类",

					}
				],

			}
		},
		onLoad(option) {

		},
		mounted() {
			this.$refs.scroll.loadData();
			// this.SetJopData();
		},
		methods: {
			goSetJopSort(item) {
				uni.navigateTo({
					url: `/pages/home/job/SetJobSort?select=${item.name}`,
				})
			},
			goSetJopSearch() {
				uni.navigateTo({
					url: "/pages/home/job/SetJopSearch"
				})
			},
			SetJopData(pageIndex, pageSize) {
				return setJobList(pageIndex, pageSize).then(res => {
					// console.log(res.data)
					return res.data;
				})
			},
			SetJopDetail(item, index) {

				let userInfo = JSON.parse(uni.getStorageSync('userInfo'));
				let isVerified = uni.getStorageSync('isVerified');
				
				if (userInfo.account_type != '劳务企业') {
					uni.navigateTo({
						url: `/pages/home/job/SetJopDetail?id=${item.id}`
					})
				} else {
					uni.showToast({
						title: '请先注册成为班组长或者劳务企业'
					})
				}

			},
		}
	}
</script>

<style lang="less" scoped>
	.recruitment-overview {
		overflow: hidden;
		height: 100vh;
		background: #F4F5F9;

		.recruitment-top {
			display: flex;
			text-align: center;
			align-items: center;
			padding: 40rpx 22rpx;
			background: #FFFFFF;

			.recruitment-search {
				width: 226rpx;
				height: 60rpx;
				display: flex;
				text-align: left;
				align-items: center;

				.image-search {
					width: 44rpx;
					height: 44rpx;
					margin-right: 12rpx;
				}

				&>input {
					flex: 1;
					font-size: 28rpx;
					font-weight: 400;
					color: #666666;
					line-height: 40rpx;
				}

				.placeholder-input {
					font-size: 28rpx;
					font-weight: 400;
					color: #666666;
					line-height: 40rpx;
				}
			}

			.recruitment-menu {
				margin-left: 30rpx;
				width: 394rpx;
				padding: 0rpx 30rpx;
				height: 80rpx;
				background: #EFF0F1;
				border-radius: 40rpx;
				display: flex;
				text-align: center;
				align-items: center;

				.recruitment-menu-item {
					flex: 0 0 34%;
					font-size: 28rpx;
					font-weight: 400;
					color: #333333;
					line-height: 40rpx;
				}
			}
		}

		.content {
			height: calc(100vh - 160rpx);

			.recruitment-item {
				background: #FFFFFF;
				margin-bottom: 20rpx;
				padding-top: 32rpx;
				padding-bottom: 40rpx;
			}
		}
	}
</style>
